<script lang="ts" setup>
import {ref} from "vue";
import type {Goods} from "@/interfaces/goods";
import {PageGoodsReqVO} from "@/interfaces/goods";
import {usePageGoodsApi} from "@/services/api";
import {onLoad, onShow} from "@dcloudio/uni-app";
import {useStore} from "vuex";

const uToastRef = ref()
const store = useStore()
const goodsList = ref<Goods[]>([])
const swiperList = ref<string[]>([
  '/static/1.jpg',
  '/static/2.jpg',
  '/static/3.jpg',
  '/static/4.jpg',
  '/static/5.png',
])
const pageGoodsReq = ref<PageGoodsReqVO>({
  current: 1,
  size: 10,
})
const init = async () => {
  const {data: res} = await usePageGoodsApi(pageGoodsReq.value)
  goodsList.value = res.list || []
}
onShow(() => {
  init()
})
onLoad(() => {
  init()
})
</script>

<template>
  <view class="container">
    <u-toast ref="uToastRef"></u-toast>
    <shop-search></shop-search>
    <shop-swiper :list="swiperList"></shop-swiper>
    <u-notice-bar fontSize="24" text="电器商城小程序"></u-notice-bar>
    <shop-goods-list :goods-list="goodsList"></shop-goods-list>
    <shop-tabbar></shop-tabbar>
  </view>
</template>

<style scoped>

</style>